<?php
	$id=$_GET['id'];
	
	
	$cateID = $_POST['cateID'];
	$groupID = $_POST['groupID'];
	$productname = $_POST['productname'];
	$target="../user/upload/products/";
	$link=$target.$_FILES['productImage']['name'];
	move_uploaded_file($_FILES['productImage']['tmp_name'],$link);
	
	$productDetail = $_POST['productDetail'];
	$productPrice = $_POST['productPrice'];
	$productWarranty = $_POST['productWarranty'];
	
	if(!empty($_POST['productHot'])){
		$productHot = $_POST['productHot'];	
	}else{
		$productHot = 0;	
	}
	
	if(!empty($_POST['promotion'])){
		$promotion = $_POST['promotion'];
	}else{
		$promotion=0;
	}	
	
	$state = $_POST['state'];
	
	$query="UPDATE productdetails SET cateID='$cateID',groupID='$groupID',productname='$productname',imgpath='$link', productDetail='$productDetail',productPrice='$productPrice',productWarranty='$productWarranty',productHot='$productHot',promotion='$promotion',state='$state' WHERE id=$id";
	
	mysql_query($query);
	echo "Sản phẩm đã được sửa thành công.";
	echo "<script>window.location='index.php?admin=productAdmin&do=listproduct'</script>";
?>